package com.shop.zkmall.app.controller.a;

import com.shop.zkmall.app.domain.req.LiveCateGoryReq;
import com.shop.zkmall.app.domain.req.LiveSearchReq;
import com.shop.zkmall.app.domain.res.RecommendRes;
import com.shop.zkmall.app.page.banner.ShopBanner;
import com.shop.zkmall.app.service.a.ICereBuyerLiveRoomService;
import com.shop.zkmall.app.service.shop.CerePlatformShopService;
import com.shop.zkmall.commons.constant.CoReturnFormat;
import com.shop.zkmall.commons.domain.buyer.CereBuyerUser;
import com.shop.zkmall.commons.domain.common.PageParam;
import com.shop.zkmall.commons.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("home")
@RequiredArgsConstructor
@Tag(name = "首页模块", description = "首页模块")
public class IndexController {

    private final CerePlatformShopService cerePlatformShopService;
    private final ICereBuyerLiveRoomService iCereBuyerLiveRoomService;

    /**
     * 查询banner
     */
    @GetMapping("getBanner")
    @Operation(summary = "查询banner")
    public Result<List<ShopBanner>> getBanner() {
        List<ShopBanner> list = cerePlatformShopService.getShopBanner();
        return new Result<>(list, CoReturnFormat.SUCCESS);
    }


    /**
     * 推荐主播
     */
    @GetMapping("recommendList")
    @Operation(summary = "推荐主播")
    public Result<List<RecommendRes>> recommendList(PageParam param) {
        List<RecommendRes> list = iCereBuyerLiveRoomService.recommendList(param);
        return new Result<>(list, CoReturnFormat.SUCCESS);
    }


    /**
     * 关注主播
     */
    @GetMapping("attentionList")
    @Operation(summary = "关注主播")
    public Result<List<RecommendRes>> attentionList(PageParam param, HttpServletRequest request) {
        CereBuyerUser user = (CereBuyerUser) request.getAttribute("user");
        List<RecommendRes> list = iCereBuyerLiveRoomService.attentionList(param,user);
        return new Result<>(list, CoReturnFormat.SUCCESS);
    }

    /**
     * 根据分类查询主播
     */
    @GetMapping("categoryList")
    @Operation(summary = "根据分类查询主播")
    public Result<List<RecommendRes>> categoryList(LiveCateGoryReq param, HttpServletRequest request) {
        CereBuyerUser user = (CereBuyerUser) request.getAttribute("user");
        List<RecommendRes> list = iCereBuyerLiveRoomService.categoryList(param,user);
        return new Result<>(list, CoReturnFormat.SUCCESS);
    }

    /**
     * 搜索直播
     */
    @GetMapping("searchLiveList")
    @Operation(summary = "搜索直播")
    public Result<List<RecommendRes>> searchLiveList(LiveSearchReq param, HttpServletRequest request) {
        CereBuyerUser user = (CereBuyerUser) request.getAttribute("user");
        List<RecommendRes> list = iCereBuyerLiveRoomService.searchLiveList(param,user);
        return new Result<>(list, CoReturnFormat.SUCCESS);
    }




}
